package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelOrdersourcetype;
import com.ktgj.hotel.service.IHotelOrdersourcetypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/ordersourcetype")
public class HotelOrdersourcetypeController extends BaseController
{
    @Autowired
    private IHotelOrdersourcetypeService hotelOrdersourcetypeService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelOrdersourcetype hotelOrdersourcetype)
    {
        startPage();
        List<HotelOrdersourcetype> list = hotelOrdersourcetypeService.selectHotelOrdersourcetypeList(hotelOrdersourcetype);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrdersourcetype hotelOrdersourcetype) throws IOException
    {
        List<HotelOrdersourcetype> list = hotelOrdersourcetypeService.selectHotelOrdersourcetypeList(hotelOrdersourcetype);
        ExcelUtil<HotelOrdersourcetype> util = new ExcelUtil<HotelOrdersourcetype>(HotelOrdersourcetype.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:query")
    @GetMapping(value = "/{ordersourcetypeid}")
    public AjaxResult getInfo(@PathVariable("ordersourcetypeid") Long ordersourcetypeid)
    {
        return AjaxResult.success(hotelOrdersourcetypeService.selectHotelOrdersourcetypeById(ordersourcetypeid));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrdersourcetype hotelOrdersourcetype)
    {
        return toAjax(hotelOrdersourcetypeService.insertHotelOrdersourcetype(hotelOrdersourcetype));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrdersourcetype hotelOrdersourcetype)
    {
        return toAjax(hotelOrdersourcetypeService.updateHotelOrdersourcetype(hotelOrdersourcetype));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "hotel:ordersourcetype:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ordersourcetypeids}")
    public AjaxResult remove(@PathVariable Long[] ordersourcetypeids)
    {
        return toAjax(hotelOrdersourcetypeService.deleteHotelOrdersourcetypeByIds(ordersourcetypeids));
    }

    /**
     * 酒店订单条件-订单来源
     * */
    @PostMapping("/selectSourcetype")
    public AjaxResult selectSourcetype() {
        List<HotelOrdersourcetype> hotelOrdersourcetypes = hotelOrdersourcetypeService.selectSourcetype();
        return AjaxResult.success(hotelOrdersourcetypes);
    }
}
